<layout name="Iflayout"/>
<script type="text/javascript">
    $(function(){

        setStyleSelect('1');//默认样式选择

        $("#form_do").submit(function(){
            var name = $("input[name='name']");
            if($.trim(name.val())==''){
                layer.tips('名称不能为空', "input[name='name']", {
                    tips: [3, '#78BA32']
                });
                return false;
            }else {
            }

        });


        $("input[name='type']").click(function(){

            var checked = $(this).prop('checked');
            var nextEname = $(this).parents('.form-group').next();//ename;

            if(checked) {
                nextEname.find('label').html('链接地址：');
                nextEname.find('span').hide();
            }else {
                nextEname.find('label').html('别名(拼音)：');
                nextEname.find('span').show();
            }

        });



        $("select[name='modelid']").change(function(){
            var styleId = $(this).val();
            setStyleSelect(styleId);
        });

        function setStyleSelect(id){
            var template_list = $("select[name='template_list']");
            var template_show = $("select[name='template_show']");
            switch (id){
                case '1':
                    //template_list.val("List_page.html");
                    template_list.find("option[value='List_page.html']").prop("selected","selected");
                    template_show.find("option[value='Show_picture.html']").prop("selected","selected");
                    break;
                case '2':
                    //template_list.val("List_page.html");
                    template_list.find("option[value='List_page.html']").prop("selected","selected");
                    template_show.find("option[value='Show_page.html']").prop("selected","selected");
                    break;
                case '3':
                    //template_list.val("List_product.html");
                    template_list.find("option[value='List_product.html']").prop("selected","selected");
                    template_show.find("option[value='Show_product.html']").prop("selected","selected");
                    break;
                case '4':
                    //template_list.val("List_picture.html");
                    template_list.find("option[value='List_picture.html']").prop("selected","selected");
                    template_show.find("option[value='Show_picture.html']").prop("selected","selected");
                    break;
                case '5':
                //template_list.val("List_soft.html");
                template_list.find("option[value='List_soft.html']").prop("selected","selected");
                template_show.find("option[value='Show_soft.html']").prop("selected","selected");
                break;
            }

        }

    });
</script>

<script type="text/javascript">
    $(function () {
        //缩略图上传
        var litpic_tip = $(".litpic_tip");
        var btn = $(".up-picture-btn span");
        $("#fileupload").wrap("<form id='myupload' action='/xyhai.php?s=/Public/upload/img_flag/1' method='post' enctype='multipart/form-data'></form>");
        $("#fileupload").change(function(){
            if($("#fileupload").val() == "") return;
            $("#myupload").ajaxSubmit({
                dataType:  'json',
                beforeSend: function() {
                    $('#litpic_show').empty();
                    btn.html("上传中...");
                },
                success: function(data) {
                    if(data.state == 'SUCCESS'){
                        var fileSize = parseFloat(data.info[0].size/1024).toFixed(2);
                        litpic_tip.html(""+ data.info[0].name +" 上传成功("+ fileSize +"k)");
                        var img = data.info[0].url;//原图
                        var timg = data.info[0].turl;//缩略图
                        $('#litpic_show').html("<img src='"+timg+"' width='120'>");
                        $("#litpic").val(timg);
                    }else {
                        litpic_tip.html(data.state);
                    }
                    btn.html("添加图片");

                },
                error:function(xhr){
                    btn.html("上传失败");
                    litpic_tip.html(xhr);
                }
            });
        });

    });




    $(function () {

        $('#BrowerPicture').click(function(){
            layer.open({
                type: 2,
                title: 'XYHCMS',
                shadeClose: true,
                shade: 0.5,
                area: ['670px', '350px'],
                content: "/xyhai.php?s=/Public/browseFile/stype/picture"
            });
        });

    });


    function selectPicture(sfile) {
        layer.msg('选择文件成功')
        $("#litpic").val(sfile);
        $('#litpic_show').html("<img src='"+sfile+"' width='120'>");
    }



</script>

<div class="xyh-content">

    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><em class="glyphicon glyphicon-cloud-upload"></em>
                添加栏目
            </h3>
        </div>

    </div>


    <div class="row">
        <div class="col-lg-12">
            <div>

                <!-- Nav tabs -->
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active">
                        <a href="#home" aria-controls="home" role="tab" data-toggle="tab">基本选项</a>
                    </li>
                    <li role="presentation">
                        <a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">高级设置</a>
                    </li>
                    <li role="presentation">
                        <a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">权限设置</a>
                    </li>
                </ul>

                <form method='post' class="form-horizontal" id="form_do" name="form_do" action="/xyhai.php?s=/Category/add">
                    <!-- Tab panes -->
                    <div class="tab-content" style="margin-top:20px;">
                        <div role="tabpanel" class="tab-pane active" id="home">
                            <div class="form-group">
                                <label for="inputProName" class="col-sm-2 control-label">所属栏目</label>
                                <div class="col-sm-9">
                                    <select name="pid" class="form-control" {$dis?'disabled="disabled"':''}>
                                        <option value="0">顶级栏目</option>
                                        <foreach name="list" item="v">
                                            <option value="{$v[id]}">{$v[name]}</option>
                                        </foreach>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="inputModelId" class="col-sm-2 control-label">内容模型</label>
                                <div class="col-sm-9">
                                    <select name="modelid" class="form-control">
                                        <option value="1">文章模型</option><option value="2">单页模型</option><option value="3">产品模型</option><option value="4">图片模型</option><option value="5">软件下载模型</option>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="inputName" class="col-sm-2 control-label">栏目名称</label>
                                <div class="col-sm-9">
                                    <input type="text" name="name" id="inputName" class="form-control" placeholder="栏目名称" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputType" class="col-sm-2 control-label">外部链接</label>
                                <div class="col-sm-9">
                                    <label class="checkbox-inline">
                                        <input type="checkbox" name="type" id="inputType" value="1" />外部链接
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEname" class="col-sm-2 control-label">别名(拼音)</label>
                                <div class="col-sm-9">
                                    <input type="text" name="ename" id="inputEname" class="form-control" />
                                    <span>只能包含字母，数字</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEname" class="col-sm-2 control-label">栏目图片</label>
                                <div class="col-sm-5">
                                    <input type="text" class="form-control" name="catpic" id="litpic"  value="" placeholder="栏目图片地址" />
                                </div>
                                <div class="col-sm-5">
                                    <button class="btn btn-primary" type="button" id="BrowerPicture"><em class="glyphicon glyphicon-plus-sign"></em> 选择站内图片</button>
                                    <div class="btn btn-success up-picture-btn">
                                        <span><em class="glyphicon glyphicon-plus-sign"></em>添加图片</span>
                                        <input id="fileupload" type="file" name="mypic">
                                    </div>
                                </div>
                            </div>


                            <div class="form-group">
                                <label for="" class="col-sm-2 control-label"></label>
                                <div class="col-sm-9">
                                    <div class="litpic_tip"></div>
                                    <div id="litpic_show"> </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="inputName" class="col-sm-2 control-label">排序</label>
                                <div class="col-sm-9">
                                    <input type="text" name="sort" id="inputSort" class="form-control" value="1" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="inputName" class="col-sm-2 control-label">显示</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline">
                                        <input type="radio" name="status" value="1" checked="checked"/>显示
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="status" value="0"/>隐藏
                                    </label>
                                </div>
                            </div>

                        </div>
                        <div role="tabpanel" class="tab-pane" id="profile">
                            <div class="form-group">
                                <label for="inputProName" class="col-sm-2 control-label">栏目模板</label>
                                <div class="col-sm-9">
                                    <select name="template_list" class="form-control">
                                        <option value="List_article.html">List_article.html</option><option value="List_page.html">List_page.html</option><option value="List_picture.html">List_picture.html</option><option value="List_product.html">List_product.html</option><option value="List_soft.html">List_soft.html</option>									</select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="inputTemplateShow" class="col-sm-2 control-label">内容页模板</label>
                                <div class="col-sm-9">
                                    <select name="template_show" id="inputTemplateShow" class="form-control">
                                        <option value="Show_article.html">Show_article.html</option><option value="Show_picture.html">Show_picture.html</option><option value="Show_product.html">Show_product.html</option><option value="Show_soft.html">Show_soft.html</option>									</select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="inputSeotitle" class="col-sm-2 control-label">Seo标题</label>
                                <div class="col-sm-9">
                                    <input type="text" name="seotitle" id="inputSeotitle" class="form-control" placeholder="Seo标题" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputKeywords" class="col-sm-2 control-label">关键词</label>
                                <div class="col-sm-9">
                                    <input type="text" name="keywords" id="inputKeywords" class="form-control" placeholder="关键词" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputDescription" class="col-sm-2 control-label">栏目描述</label>
                                <div class="col-sm-9">
                                    <textarea name="description" id="inputDescription" class="form-control" placeholder="栏目描述"></textarea>
                                </div>
                            </div>

                        </div>
                        <div role="tabpanel" class="tab-pane" id="messages">
                            <div class="form-group">
                                <label for="inputProName" class="col-sm-2 control-label">管理员组权限</label>
                                <div class="col-sm-9">
                                    <table class="table table-hover xyh-table-bordered-out-small">
                                        <thead>
                                        <tr class="active">
                                            <th>管理员组名称</th>
                                            <th>查看</th>
                                            <th>添加</th>
                                            <th>修改</th>
                                            <th>删除</th>
                                            <th>移动</th>
                                            <th>回收站</th>
                                            <th>还原</th>
                                            <th>清除</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr>
                                            <td>管理员</td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="index,1" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="add,1" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="edit,1" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="del,1" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="move,1" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="trach,1" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="restore,1" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="clear,1" /></td>
                                        </tr><tr>
                                            <td>产品组</td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="index,2" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="add,2" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="edit,2" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="del,2" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="move,2" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="trach,2" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="restore,2" /></td>
                                            <td align="center"><input type="checkbox" name="acc_roleid[]" value="clear,2" /></td>
                                        </tr>										  </tbody>
                                    </table>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="inputTemplateShow" class="col-sm-2 control-label">会员组权限</label>
                                <div class="col-sm-9">
                                    <table class="table table-hover xyh-table-bordered-out-small">
                                        <thead>
                                        <tr class="active">
                                            <th>会员组名称</th>
                                            <th>允许访问</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr>
                                            <td>游客</td>
                                            <td align="center"><input type="checkbox" name="acc_groupid[]" value="visit,1" /></td>
                                        </tr><tr>
                                            <td>注册会员</td>
                                            <td align="center"><input type="checkbox" name="acc_groupid[]" value="visit,2" /></td>
                                        </tr><tr>
                                            <td>中级会员</td>
                                            <td align="center"><input type="checkbox" name="acc_groupid[]" value="visit,3" /></td>
                                        </tr>									  </tbody>
                                    </table>
                                </div>
                            </div>

                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-offset-2 col-sm-9">
                            <div class="btn-group">
                                <button type="submit" class="btn btn-primary"> <i class="glyphicon glyphicon-saved"></i>
                                    保存
                                </button>
                                <button type="button" onclick="goUrl('/xyhai.php?s=/Category/index')" class="btn btn-default"> <i class="glyphicon glyphicon-chevron-left"></i>
                                    返回
                                </button>
                            </div>
                        </div>
                    </div>
                </form>

            </div>

        </div>
    </div>






</div>
</body>
</html>